package com.hikeen.launcherx.functions.hotspot;


import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.util.Log;


/**
 * 广播监听热点状态
 */


public class HotSpotStateReceiver extends BroadcastReceiver {
    public static int DEFAULT_VALUE_BULUETOOTH = 1000;
    public static OnHotSpotStateListener mOnHotSpotStateListener;
    private String TAG = "HotSpotBroadCastReceiver";



    @Override
    public void onReceive(Context context, Intent intent) {

        String action = intent.getAction();
        if("android.net.wifi.WIFI_AP_STATE_CHANGED".equals(action)){
            //便携式热点的状态为：10---正在关闭；11---已关闭；12---正在开启；13---已开启
            int state = intent.getIntExtra("wifi_state",  0);
            Log.e(TAG,"热点开关状态：state= "+String.valueOf(state));
            if(state == 13){
                Log.e(TAG,"热点已开启");
                mOnHotSpotStateListener.onStateEnable();
            }else if(state == 11){
                Log.e(TAG,"热点已关闭");
                mOnHotSpotStateListener.onStateDisable();
            }else if(state == 10){
                Log.e(TAG,"热点正在关闭");
                mOnHotSpotStateListener.onCloseing();
            }else if(state == 12){
                Log.e(TAG,"热点正在开启");
                mOnHotSpotStateListener.onOpening();
            }
        }

    }



    public static void setHotSpotStateListener(OnHotSpotStateListener onHotSpotStateListener) {
         mOnHotSpotStateListener = onHotSpotStateListener;
    }

}
